package com.by.controllers;





import com.by.models.ChannelModel;
import com.by.models.DataModel;
import com.by.models.GametypeModel;
import com.by.models.HiddenCModel;
import com.by.models.TempModel;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.render.ViewType;

public class MyConfig extends JFinalConfig {

	@Override
	public void configConstant(Constants me) {
		// TODO Auto-generated method stub				
		me.setDevMode(true);
		me.setViewType(ViewType.JSP);
		loadPropertyFile("properties/db.properties");
	}

	@Override
	public void configRoute(Routes me) {
	
		me.add("/", UserPage.class);
	
	}

	@Override
	public void configPlugin(Plugins me) {
		
		DruidPlugin plugin = new DruidPlugin(getProperty("jdbcUrl"), getProperty("user"), getProperty("password"));
		me.add(plugin);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(plugin);
		me.add(arp);
		arp.addMapping("channel", ChannelModel.class);
		arp.addMapping("data", DataModel.class);
		arp.addMapping("temp", TempModel.class);
		arp.addMapping("gametype", GametypeModel.class);
		arp.addMapping("hiddenC", HiddenCModel.class);
		
	}
	
	@Override
	public void configInterceptor(Interceptors me) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void configHandler(Handlers me) {
		// TODO Auto-generated method stub
		//me.add(new FilterHandler());
	}
	
	@Override
	public void afterJFinalStart() {
		
		//new AutoUpdate().auto();
	}
}
